﻿@model SmartParking.Web.Models.ReservationListModel
@{
    ViewBag.Title = Model.ViewTitle;
    var modelAsJSON = new HtmlString(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model));
}

<div>
    @Html.Partial("List", new SmartParking.Web.Models.ListModel(Model))
    @if (Model.Reservations.Any())
    {
        var subtotal = Model.Reservations.Sum(item => Convert.ToDecimal(item.Amount));
        var subtotal2 = subtotal / SmartParking.Bussiness.SmartParkingSettings.TipoCambio;
        var comission = Model.Reservations.Sum(item => Convert.ToDecimal(item.Comission));
        var comission2 = comission / SmartParking.Bussiness.SmartParkingSettings.TipoCambio;
        <div data-role="fieldcontain">
            <label for="lbSubtotal">
                Subtotal
            </label>
            <input id="lbSubtotal" name="lbSubtotal" type="text" value="$@subtotal2 (¢@subtotal)" readonly="readonly" style="text-align: right"/>
        </div>
        <div data-role="fieldcontain">
            <label for="lbComission">
                Comisión
            </label>
            <input id="lbComission" name="lbComission" type="text" value="$@comission2 (¢@comission)" readonly="readonly" style="text-align: right"/>
        </div>
        <div data-role="fieldcontain">
            <label for="lbTotal">
                Total
            </label>
            <input id="lbTotal" name="lbTotal" type="text" value="$@(subtotal2 + comission2) (¢@(subtotal + comission))" readonly="readonly" style="text-align: right"/>
        </div>
        <div style="text-align: center">
            <input id="cmdPayPal" type="image" src='@SmartParking.Bussiness.PayPalSettings.PayPalPayNowButtonUrl' style="width: 65%; visibility: visible" alt="PayPal - The safer, easier way to pay online!">
        </div>
    }
</div>

@section scripts {
    <script type='text/javascript'>
        $(document).on("click", "#cmdPayPal", null, function() {
            window.location = '@SmartParking.Bussiness.PayPalSettings.PaymentUrl';
        });
        function listAction(id) {
            var url = "@Url.Action(Model.ItemDeleteView)/" + id;
            var result = false;
            $.post(url, id, function () { result = true; }).always(function () { doReload(); });
            return result;
        }
    </script>
}
